package iterator;

import java.util.ArrayList;
import java.util.Collection;

public class ForEachDemo {
    public static void main(String[] args) {
        Collection<String> list = new ArrayList<>();
        list.add("张三丰");
        list.add("张翠山");
        list.add("张无忌");
        System.out.println("list = " + list);


        for (String name : list){
            if (name.equals("张翠山")){
                list.add("殷素素");
            }
            System.out.println("name = " + name);
        }
        System.out.println("list = " + list);
        int[] arr = {1,2,3,4,5};
        for (int num : arr){
            System.out.println("num = " + num);
        }
    }
}
